home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / DIALOG.ZIP / DBPRO2-@.EXE / CLONE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-20  |  18.5 KB  |  596 lines

  1. #include "pro.h"
  2. #include "xglobals.h"
  3. #include "dbpro.h"
  4. #include "colors.h"
  5. #include "xcodes.h"
  6. #include "video.h"
  7. #include "vidmodes.h"
  8. #include <string.h>
  9. #include <conio.h>
  10.  
  11. void main(void);
  12.  
  13. char db_available[] = {        /* the dialog box consists of several questions */
  14.     1,                        /* this array indicates which questions can */
  15.     1,                        /* be modified, 1-yes, 0-no */
  16.     1,
  17.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  18. };
  19.  
  20. /* definition of each question used in the dialog box */
  21.  
  22. title proglist = {
  23.     TITLE,
  24.     0,
  25.     "Program List: <None>",
  26.     2,2,
  27.     FALSE
  28. };
  29.  
  30. title currfile = {
  31.     TITLE,
  32.     0,
  33.     "Current File: untitled.c",
  34.     2,3,
  35.     FALSE
  36. };
  37.  
  38. title warnlevels = {
  39.     TITLE,
  40.     0,
  41.     "Warning Levels",
  42.     2,5,
  43.     FALSE
  44. };
  45.  
  46. title outputoptions = {
  47.     TITLE,
  48.     0,
  49.     "Output Options",
  50.     19,5,
  51.     FALSE
  52. };
  53.  
  54. title miscellaneous = {
  55.     TITLE,
  56.     0,
  57.     "Miscellaneous",
  58.     44,5,
  59.     FALSE
  60. };
  61.  
  62. rcbutton level0 = {
  63.     RCBUTTON,                /* question type */
  64.     0,                        /* tile handle */
  65.     NULL, NULL, NULL,        /* in, out, and action */
  66.     " Level ~0",                /* statement */
  67.     5, 6,                    /* statement x, y */
  68.     XALT0,                    /* shortcut key */
  69.     RADIO(0),                /* radio button group */
  70.     TRUE,                    /* default button checked */
  71.     NULL                    /* target variable */
  72. };
  73.  
  74. rcbutton level1 = {
  75.     RCBUTTON,                /* question type */
  76.     0,                        /* tile handle */
  77.     NULL, NULL, NULL,        /* in, out, and action */
  78.     " Level ~1",                /* statement */
  79.     5, 7,                    /* statement x, y */
  80.     XALT1,                    /* shortcut key */
  81.     RADIO(0),                /* radio button group */
  82.     FALSE,                    /* button checked? */
  83.     NULL                    /* target variable */
  84. };
  85.  
  86. rcbutton level2 = {
  87.     RCBUTTON,                /* question type */
  88.     0,                        /* tile handle */
  89.     NULL, NULL, NULL,        /* in, out, and action */
  90.     " Level ~2",                /* statement */
  91.     5, 8,                    /* statement x, y */
  92.     XALT2,                    /* shortcut key */
  93.     RADIO(0),                /* radio button group */
  94.     FALSE,                    /* checked? */
  95.     NULL                    /* target variable */
  96. };
  97.  
  98. rcbutton level3 = {
  99.     RCBUTTON,                /* question type */
  100.     0,                        /* tile handle */
  101.     NULL, NULL, NULL,        /* in, out, and action */
  102.     " Level ~3",                /* statement */
  103.     5, 9,                    /* statement x, y */
  104.     XALT3,                    /* shortcut key */
  105.     RADIO(0),                /* radio button group */
  106.     FALSE,                    /* checked */
  107.     NULL                    /* target variable */
  108. };
  109.  
  110. rcbutton obj = {
  111.     RCBUTTON,                /* question type */
  112.     0,                        /* tile handle */
  113.     NULL, NULL, NULL,        /* in, out, and action */
  114.     " ~Obj",                    /* statement */
  115.     22, 6,                    /* statement x, y */
  116.     XALTO,                    /* shortcut key */
  117.     RADIO(1),                /* radio button group */
  118.     TRUE,                    /* checked? */
  119.     NULL                    /* target variable */
  120. };
  121.  
  122. rcbutton memory = {
  123.     RCBUTTON,                /* question type */
  124.     0,                        /* tile handle */
  125.     NULL, NULL, NULL,        /* in, out, and action */
  126.     " ~Memory",                /* statement */
  127.     22, 7,                    /* statement x, y */
  128.     XALTM,                    /* shortcut key */
  129.     RADIO(1),                /* radio button group */
  130.     FALSE,                    /* checked? */
  131.     NULL                    /* target variable */
  132. };
  133.  
  134. rcbutton exe = {
  135.     RCBUTTON,                /* question type */
  136.     0,                        /* tile handle */
  137.     NULL, NULL, NULL,        /* in, out, and action */
  138.     " E~xe",                    /* statement */
  139.     22, 8,                    /* statement x, y */
  140.     XALTX,                    /* shortcut key */
  141.     RADIO(1),                /* radio button group */
  142.     FALSE,                    /* checked? */
  143.     NULL                    /* target variable */
  144. };
  145.  
  146. rcbutton syntax = {
  147.     RCBUTTON,                /* question type */
  148.     0,                        /* tile handle */
  149.     NULL, NULL, NULL,        /* in, out, and action */
  150.     " S~yntax Check Only",    /* statement */
  151.     22, 9,                    /* statement x, y */
  152.     XALTY,                    /* shortcut key */
  153.     RADIO(1),                /* radio button group */
  154.     FALSE,                    /* checked? */
  155.     NULL                    /* target variable */
  156. };
  157.  
  158. rcbutton debug = {
  159.     RCBUTTON,                /* question type */
  160.     0,                        /* tile handle */
  161.     NULL, NULL, NULL,        /* in, out, and action */
  162.     " ~Debug",                /* statement */
  163.     47, 6,                    /* statement x, y */
  164.     XALTD,                    /* shortcut key */
  165.     CHECK,                    /* checkbox! */
  166.     FALSE,                    /* checked? */
  167.     NULL                    /* target variable */
  168. };
  169.  
  170. rcbutton pointer = {
  171.     RCBUTTON,                /* question type */
  172.     0,                        /* tile handle */
  173.     NULL, NULL, NULL,        /* in, out, and action */
  174.     " ~Pointer Check",        /* statement */
  175.     47, 7,                    /* statement x, y */
  176.     XALTP,                    /* shortcut key */
  177.     CHECK,                    /* checkbox! */
  178.     FALSE,                    /* checked? */
  179.     NULL                    /* target variable */
  180. };
  181.  
  182. rcbutton stack = {
  183.     RCBUTTON,                /* question type */
  184.     0,                        /* tile handle */
  185.     NULL, NULL, NULL,        /* in, out, and action */
  186.     " ~Stack Check",            /* statement */
  187.     47, 8,                    /* statement x, y */
  188.     XALTS,                    /* shortcut key */
  189.     CHECK,                    /* checkbox! */
  190.     FALSE,                    /* checked? */
  191.     NULL                    /* target variable */
  192. };
  193.  
  194. rcbutton language = {
  195.     RCBUTTON,                /* question type */
  196.     0,                        /* tile handle */
  197.     NULL, NULL, NULL,        /* in, out, and action */
  198.     " ~Language Extensions",    /* statement */
  199.     47, 9,                    /* statement x, y */
  200.     XALTL,                    /* shortcut key */
  201.     CHECK,                    /* checkbox! */
  202.     FALSE,                    /* checked? */
  203.     NULL                    /* target variable */
  204. };
  205.  
  206. rcbutton optimize = {
  207.     RCBUTTON,                /* question type */
  208.     0,                        /* tile handle */
  209.     NULL, NULL, NULL,        /* in, out, and action */
  210.     " Optimi~zations",        /* statement */
  211.     47, 10,                    /* statement x, y */
  212.     XALTZ,                    /* shortcut key */
  213.     CHECK,                    /* checkbox! */
  214.     FALSE,                    /* checked? */
  215.     NULL                    /* target variable */
  216. };
  217.  
  218. free_form incs = {
  219.     FREE_FORM,              /* question type */
  220.     0,                        /* tile handle -- if your dialog box consists
  221.                                of several virtual screens you can indicate
  222.                                which virtual screen the question is
  223.                                displayed in
  224.                             */
  225.     NULL, NULL, NULL,        /* in - this routine will be executed when the
  226.                                question is initially highlighted.
  227.                                out - this routine will be executed when the
  228.                                question is dehighlighted,
  229.                                action - this routine will be executed each
  230.                                time the question is exited (e.g. when you
  231.                                exit the free_form line editor)
  232.                             */
  233.     "~Include:",            /* statement */
  234.     2, 13,                    /* statement x, y */
  235.     XALTI,                    /* shortcut key - the actual keypress value
  236.                                which when recognized will navigate directly
  237.                                to this question
  238.                             */
  239.     NULL, "",                /* response & default response - the response
  240.                                contains the current response to the question
  241.                                typically you would assign this a NULL value,
  242.                                if you do assign it a value make sure that it
  243.                                is a pointer to a dynamically allocated memory
  244.                                block.
  245.  
  246.                                default response - if response is NULL db_run
  247.                                uses a dynamically allocated copy of the
  248.                                default response as the actual response.
  249.                             */
  250.     12, 13, 58,                /* response x, y, and length - indicates where
  251.                                to display the response string and how many
  252.                                characters to devote to the display area
  253.                             */
  254.     NULL,                    /* insurance -- typically set to NULL, this
  255.                                member of the structure is used to keep
  256.                                a copy of the string when it is edited, if
  257.                                the user wants to restore the original
  258.                                string we use this copy to recreate it
  259.                             */
  260.     NULL,                    /* target -- this char** is updated to the
  261.                                same value as response on exiting the
  262.                                dialog box.  You can use this to have
  263.                                dialog boxes update global (or local)
  264.                                variables in your existing routines.
  265.                             */
  266.     0,                        /* cursor position - indicates the default
  267.                                position of the edit cursor on editing
  268.                                the response string
  269.                             */
  270.     NULL,                    /* macros - if you want to have some special
  271.                                macros during the line editor process
  272.                                assign them here.
  273.                             */
  274.     TRUE                    /* refresh -- tells it to draw the statement
  275.                                and delimiters.  Always set this to TRUE
  276.                                when initializing a structure */
  277. };
  278.  
  279. free_form def = {
  280.     FREE_FORM,              /* question type */
  281.     0,                        /* tile handle -- if your dialog box consists
  282.                                of several virtual screens you can indicate
  283.                                which virtual screen the question is
  284.                                displayed in
  285.                             */
  286.     NULL, NULL, NULL,        /* in - this routine will be executed when the
  287.                                question is initially highlighted.
  288.                                out - this routine will be executed when the
  289.                                question is dehighlighted,
  290.                                action - this routine will be executed each
  291.                                time the question is exited (e.g. when you
  292.                                exit the free_form line editor)
  293.                             */
  294.     "De~fine:",                /* statement */
  295.     2, 16,                    /* statement x, y */
  296.     XALTF,                    /* shortcut key - the actual keypress value
  297.                                which when recognized will navigate directly
  298.                                to this question
  299.                             */
  300.     NULL, "",                /* response & default response - the response
  301.                                contains the current response to the question
  302.                                typically you would assign this a NULL value,
  303.                                if you do assign it a value make sure that it
  304.                                is a pointer to a dynamically allocated memory
  305.                                block.
  306.  
  307.                                default response - if response is NULL db_run
  308.                                uses a dynamically allocated copy of the
  309.                                default response as the actual response.
  310.                             */
  311.     12, 16, 58,                /* response x, y, and length - indicates where
  312.                                to display the response string and how many
  313.                                characters to devote to the display area
  314.                             */
  315.     NULL,                    /* insurance -- typically set to NULL, this
  316.                                member of the structure is used to keep
  317.                                a copy of the string when it is edited, if
  318.                                the user wants to restore the original
  319.                                string we use this copy to recreate it
  320.                             */
  321.     NULL,                    /* target -- this char** is updated to the
  322.                                same value as response on exiting the
  323.                                dialog box.  You can use this to have
  324.                                dialog boxes update global (or local)
  325.                                variables in your existing routines.
  326.                             */
  327.     0,                        /* cursor position - indicates the default
  328.                                position of the edit cursor on editing
  329.                                the response string
  330.                             */
  331.     NULL,                    /* macros - if you want to have some special
  332.                                macros during the line editor process
  333.                                assign them here.
  334.                             */
  335.     TRUE                    /* refresh -- tells it to draw the statement
  336.                                and delimiters.  Always set this to TRUE
  337.                                when initializing a structure */
  338. };
  339.  
  340. button buildprog = {
  341.  
  342.     /************************* same as above *********************/
  343.     BUTTON,                    /* question type */
  344.     0,                        /* tile handle */
  345.     NULL, NULL, NULL,        /* in, out, and action */
  346.     " ~Build Program ",                /* statement */
  347.     4, 20,                    /* statement x, y */
  348.     XALTB,                    /* shortcut key */
  349.  
  350.     /*************** these fields are unique to buttons ***********/
  351.     box0,                    /* border characters - if you want the
  352.                                button statement surrounded by a box
  353.                                indicate the box type here.  Otherwise
  354.                                set this field to NULL.
  355.                             */
  356.     HEAD_ON,                /* shading - if your button is surrounded
  357.                                by a box you can use a shadowing effect
  358.                                with this field.
  359.                             */
  360.     XENTER,                    /* hitting button is = XENTER - when a button
  361.                                is pressed it simply pushes a key value
  362.                                or db opcode onto the queue.  The
  363.                                interpretation of this value can then
  364.                                do things like confirm the dialog box, etc.
  365.                                If you do not want to use this feature of
  366.                                buttons assign this field a value of
  367.                                DO_NOTHING.
  368.                             */
  369.     XENTER,                    /* flash key - you can 'press' a button without
  370.                                changing the selected question to the button
  371.                                by pressing this key value.  Note that the
  372.                                mouse routines simply put the shortcut key
  373.                                value in the queue when you press and release
  374.                                on a button and they put this key value into
  375.                                the queue when you quickly click on a button.
  376.                                As such this must be a unique value, otherwise
  377.                                clicking on this button, could actually activate
  378.                                another button.  Note that the value does
  379.                                not have to be a keyboard generatable value it
  380.                                should just be unique to the other shortcut keys.
  381.                             */
  382.     FALSE,                    /* continuous - if holding the mouse button down
  383.                                and sitting on a dialog box button should
  384.                                continuously push shortcut key values onto the
  385.                                queue indicate TRUE in this field, otherwise
  386.                                indicate FALSE.  Generally you would indicate
  387.                                TRUE if it made sense for the button to perform
  388.                                some continuous action if you held the mouse
  389.                                cursor on it.  For example, if you had button
  390.                                which 'flipped' through a series of records
  391.                                you might make this field TRUE.
  392.                             */
  393.     20                        /* exit value - if the button results in
  394.                                exiting the dialog box you can change the
  395.                                exit value with this field.  You can use
  396.                                this if you want to specifically determine
  397.                                that a user exited by using a certain
  398.                                button.
  399.                             */
  400. };
  401.  
  402. button compfile = {
  403.  
  404.     /************************* same as above ***************************/
  405.     BUTTON,                    /* question type */
  406.     0,                        /* tile handle */
  407.     NULL, NULL, NULL,        /* in, out, and action */
  408.     " ~Compile File ",        /* statement */
  409.     23, 20,                    /* statement x, y */
  410.     XALTC,                    /* shortcut key */
  411.     box1,                    /* border characters */
  412.     HEAD_ON,                /* shading */
  413.     XENTER,                    /* hitting button is = XESC */
  414.     -100,                    /* flash key */
  415.     FALSE,                    /* continuous */
  416.     21                        /* exit value */
  417. };
  418.  
  419. button rebuild = {
  420.  
  421.     /************************* same as above ***************************/
  422.     BUTTON,                    /* question type */
  423.     0,                        /* tile handle */
  424.     NULL, NULL, NULL,        /* in, out, and action */
  425.     " ~Rebuild All ",        /* statement */
  426.     41, 20,                    /* statement x, y */
  427.     XALTR,                    /* shortcut key */
  428.     box1,                    /* border characters */
  429.     HEAD_ON,                /* shading */
  430.     XENTER,                    /* hitting button is = XESC */
  431.     -101,                    /* flash key */
  432.     FALSE,                    /* continuous */
  433.     22                        /* exit value */
  434. };
  435.  
  436. button cancel = {
  437.  
  438.     /************************* same as above ***************************/
  439.     BUTTON,                    /* question type */
  440.     0,                        /* tile handle */
  441.     NULL, NULL, NULL,        /* in, out, and action */
  442.     " Cancel ",                /* statement */
  443.     58, 20,                    /* statement x, y */
  444.     -102,                    /* shortcut key */
  445.     box1,                    /* border characters */
  446.     HEAD_ON,                /* shading */
  447.     XESC,                    /* hitting button is = XESC */
  448.     XESC,                    /* flash key */
  449.     FALSE,                    /* continuous */
  450.     ABORTED                    /* exit value */
  451. };
  452.  
  453. void *simple_questions[] = {
  454.     &proglist,
  455.     &currfile,
  456.     &warnlevels,
  457.     &outputoptions,
  458.     &miscellaneous,
  459.     &level0,
  460.     &level1,
  461.     &level2,
  462.     &level3,
  463.     &obj,
  464.     &memory,
  465.     &exe,
  466.     &syntax,
  467.     &debug,
  468.     &pointer,
  469.     &stack,
  470.     &language,
  471.     &optimize,
  472.     &incs,
  473.     &def,
  474.     &buildprog,
  475.     &compfile,
  476.     &rebuild,
  477.     &cancel,
  478.     NULL
  479. };
  480.  
  481. dialog_box simple_db = {
  482.  
  483.     MAX_WINDOWS,            /*     window handle -- set this to MAX_WINDOWS
  484.                                 if you want db_run to create the window
  485.                                 for you
  486.                             */
  487.     NULL, NULL,                /*     post-size and post-move routines -- after
  488.                                 sizing or moving a dialog box these
  489.                                 routines will be executed
  490.                             */
  491.     TRUE, TRUE,                /*     move and size OK -- set these to TRUE if
  492.                                 it is OK to move or size the dialog box
  493.                             */
  494.     simple_questions,        /*     questions -- set this to the array of
  495.                                 questions which comprise the dialog box
  496.                             */
  497.     db_available,            /*     available questions -- this is an array of 1s
  498.                                 an 0s where 1 indicates that a user can modify
  499.                                 the response to the question and 0 indicates
  500.                                 that it is not allowed.
  501.                             */
  502.     0,                        /*     selected question -- indicates the currently */
  503.     default_db_cmds,        /*     keyboard commands -- an array of ints which
  504.                                 assigns each db opcode to a keypress, e.g.
  505.                                 you might assign XENTER to CONFIRM and XESC
  506.                                 to ABORT.
  507.                             */
  508.     FALSE,                    /*     If FALSE the dialog box will be automatically
  509.                                 brought to the top of the window stack when
  510.                                 activated.  Otherwise, you will be able to
  511.                                 run the dialog box but other windows may
  512.                                 obscure it.  Normally set to TRUE for menu
  513.                                 bars, or some sort of dialog box which
  514.                                 represents a desktop.  For example you
  515.                                 could represent the Framework II desktop
  516.                                 as a background dialog box.
  517.                             */
  518.     &default_db_colors,        /*     db_colors -- an array of unsigned chars
  519.                                 containing video attributes to use for
  520.                                 various parts of a dialog box
  521.                             */
  522.     &default_db_delimiters,    /*     db delimiters -- an array of chars which
  523.                                 are used to delimit the response areas
  524.                                 for various question types
  525.                             */
  526.     NULL,                    /*     insurance -- normally set to NULL, this
  527.                                 pointer is used internally by db_run.
  528.                                 When a dialog box is activated a copy
  529.                                 of the current responses is made and
  530.                                 pointed to by this field.  If the
  531.                                 user ABORTS the dialog box we restore
  532.                                 the original responses using this
  533.                                 copy.
  534.                             */
  535.     NULL,                    /*     macros -- indicates any special macros for
  536.                                 this dialog box.
  537.                             */
  538.  
  539.                             /*     All of these are used to create a
  540.                                 window to display the dialog box in
  541.                                 if the above window handle does not
  542.                                 exist.
  543.                             */
  544.     23, 71,                    /* virtual rows and columns */
  545.     1, 1,                    /* physical x & y */
  546.     1, 1,                    /* virtual x & y */
  547.     23, 71,                    /* viewport rows & columns */
  548.     HEAD_ON,                /* shading style */
  549.     NULL,                    /* primary dialog box name */
  550.     NULL,                    /* secondary dialog box name */
  551.     box1,                    /* window border characters */
  552.     NONE,                    /* scroll bars style */
  553.     red, lightgray            /* virtual screen attribute */
  554. };
  555.  
  556. void main()
  557. {
  558.     unsigned char head = 0, tail = 0;
  559.     unsigned int queue[256];
  560.  
  561.     /* initialize The WINDOW PRO - required */
  562.     wn_init();
  563.  
  564.     /* initialize The DB PRO message queue - required */
  565.     db_switchqueue(&head, &tail, queue);
  566.  
  567.     if (v_getmode() == mono) {
  568.         simple_db.colors = &msmono;
  569.         active_attr = lightgray + (black << 4);
  570.         simple_db.fg = lightgray;
  571.         simple_db.bg = black;
  572.     }
  573.     else active_attr = black + (lightgray << 4);
  574.  
  575.     /* execute the dialog box */
  576.     db_run(&simple_db, 0);
  577.  
  578.     /* get rid of the dialog box - if memory is tight you can deleted
  579.        the dialog box window each time. Doing this will slow down
  580.        execution but allow you to cram in more data.  Note that
  581.        if you delete a dialog box window you should reset the
  582.        window handle back to MAX_WINDOWS.  When a window handle
  583.        is deleted it is returned to the free handles pool.  If the
  584.        handle were to get reused and this dialog box were rerun
  585.        it would believe that it had a valid window handle and
  586.        would not create a new window (of the proper size and location.)
  587.     */
  588.     wn_delw(simple_db.handle); simple_db.handle = MAX_WINDOWS;
  589.  
  590.     /* restore the cursor position */
  591.     v_gotoxy(oldx,oldy);
  592.  
  593.     /* restore the cursor shape */
  594.     v_curshape(oldb, olde);
  595. }
  596.